package cn.dujc.superkid.activities;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import cn.dujc.core.ui.BaseActivity;
import cn.dujc.superkid.R;
import cn.dujc.superkid.fragment.research.AboutResearchFragment;
import cn.dujc.superkid.fragment.research.ContactUsFragment;
import cn.dujc.superkid.fragment.research.TeachersFragment;

/**
 * @author du
 * date 2018/8/2 上午12:06
 */
public class ResearchActivity extends BaseActivity {

    private final String[] mTitles = {"研究院介绍", "教师介绍", "联系我们"};
    private final Fragment[] mFragments = {new AboutResearchFragment(), new TeachersFragment(), new ContactUsFragment()};
    private TabLayout mTlTabs;
    private ViewPager mVpContent;

    @Override
    public int getViewId() {
        return R.layout.activity_research;
    }

    @Override
    public void initBasic(Bundle savedInstanceState) {
        setTitle("研究院介绍");
        mTlTabs = findViewById(R.id.tl_tabs);
        mVpContent = findViewById(R.id.vp_content);
        initUI();
    }

    private void initUI() {
        final FragmentPagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {
            @Override
            public int getCount() {
                return mTitles.length;
            }

            @Override
            public Fragment getItem(int position) {
                return mFragments[position];
            }

            @Override
            public CharSequence getPageTitle(int position) {
                return mTitles[position];
            }
        };
        mVpContent.setAdapter(pagerAdapter);
        mTlTabs.setupWithViewPager(mVpContent);
    }
}
